package com.bawei.property.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.bawei.property.R
import com.bawei.property.databinding.ItemCarImgBinding
import com.bawei.property.entity.CarImageEntity

/**
 * Author: Jason Zhang
 * Date: 2024/8/31
 * Desc:
 */
class CarImageAdapter constructor(private val list: MutableList<CarImageEntity>): RecyclerView.Adapter<CarImageAdapter.ItemViewHolder>() {

    inner class ItemViewHolder(val binding: ItemCarImgBinding) : RecyclerView.ViewHolder(binding.root)

    override fun getItemCount(): Int = list.size

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {
        var dataBinding = DataBindingUtil.inflate<ItemCarImgBinding>(LayoutInflater.from(parent.context), R.layout.item_car_img, parent, false)
        return ItemViewHolder(dataBinding)
    }

    override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
        holder.binding.entity = list[position]
        holder.binding.executePendingBindings()
    }


}